package ael.imarkket.Library;

import android.util.Log;

public class Logging {
	public static final String	TAG			= "DEBUG";

	public static final int		LOG_VERBOSE	= 0;
	public static final int		LOG_DEBUG	= 1;
	public static final int		LOG_INFO	= 2;
	public static final int		LOG_WARNING	= 3;
	public static final int		LOG_ERROR	= 4;

	private static Logging		instance;
	private static boolean		actif;

	public static Logging getInstance() {
		if (null == instance)
			instance = new Logging();
		return instance;
	}

	private Logging() {
		Logging.setActif(true);
	}

	public void log(Integer type, String mensaje) {
		/*
		 * Log.v(); // Verbose Log.d(); // Debug Log.i(); // Info Log.w(); // Warning Log.e(); // Error
		 */
		if (isActif()) {

			switch (type) {
				case LOG_VERBOSE:
					Log.v(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
					break;
				case LOG_DEBUG:
					Log.d(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
					break;
				case LOG_INFO:
					Log.i(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
					break;
				case LOG_WARNING:
					Log.w(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
					break;
				case LOG_ERROR:
					Log.e(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
					break;
			}
		}
	}

	public static boolean isActif() {
		return actif;
	}

	public static void setActif(boolean actif) {
		Logging.actif = actif;
	}
}
